$(function () {
    const user = $('#user');
    const pw = $('#password');
    const loginButton = $('#login');

    const messageDiv = $('#login_sign_div');
    const message = $('#login_sign');

    loginButton.click(function () {
        $.post('/users/signin', {username: user.val(), password: pw.val()}, function (res) {
            if (res && res.error) {
                messageDiv.show();
                message.val(res.error.message).css('color', 'red');
            } else if (res && res.success) {
                console.log(res.success);
                location.reload();
            }
        });
    });
});
